import { defineStore } from "pinia";
import { ref } from "vue";

export const useStepStore = defineStore("step", () => {
  // 当前活动步骤，0: 登录微信, 1: 配置转发规则, 2: 开始转发
  const activeStep = ref(0);

  // 设置步骤
  function setStep(step) {
    if (step >= 0 && step <= 2) {
      activeStep.value = step;
    }
  }

  // 进入下一步
  function nextStep() {
    if (activeStep.value < 2) {
      activeStep.value++;
    }
  }

  // 返回上一步
  function prevStep() {
    if (activeStep.value > 0) {
      activeStep.value--;
    }
  }

  return {
    activeStep,
    setStep,
    nextStep,
    prevStep,
  };
});
